package com.zhuzi.component;

import com.zhuzi.service.JcNewsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.time.LocalDate;

/**
 * @author zhuzi
 * 2022/8/8 19:42
 * 初始化方法
 */
@Slf4j
@Component
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class InitMethod {
    final KzzComponent kzzComponent;
    final JcNewsService jcNewsService;

    /**
     * 可转债代码抓取
     */
    @Scheduled(cron = "0 0 16 ? * MON-FRI")
    @PostConstruct
    public void kzzCodeAndStock() {
        //抓取全部可转债
        kzzComponent.getKzzAndStock();
    }

    @Scheduled(cron = "0 08 15,17,21,22 * * ?")
    public void jcForeshow() {
        jcNewsService.jcNews("业绩预告", LocalDate.now(), LocalDate.now().plusDays(1), "业绩预告", false);
    }

    @Scheduled(cron = "0 0/15 16-21 * * ?")
    public void jcKzzRedeem() {
        jcNewsService.jcNews("提前赎回", LocalDate.now(), LocalDate.now().plusDays(1), "提前赎回?", false);
    }

    @Scheduled(cron = "0 0/15 16-21 * * ?")
    public void jcKzzAmend() {
        jcNewsService.jcNews("向下;修正;下修", LocalDate.now(), LocalDate.now().plusDays(1), "下修提示", false);
    }
}
